const crypto = require('crypto');

// MD5加密方法
function md5(input) {
    return crypto.createHash('md5').update(input, 'utf8').digest('hex');
}

// MD5加盐加密方法
function md5WithSalt(input, salt) {
    return md5(input + salt);
}

// MD5多次加密
function md5MultipleTimes(input, times) {
    let result = input;
    for (let i = 0; i < times; i++) {
        result = md5(result);
    }
    return result;
}

// 测试
const input = "hello";
const salt = "randomSalt";

console.log("MD5:", md5(input));
console.log("MD5 with Salt:", md5WithSalt(input, salt));
console.log("MD5 Multiple Times:", md5MultipleTimes(input, 3));
